<script setup lang="ts">
import { onMounted } from 'vue'
import AMapLoader from '@amap/amap-jsapi-loader'
import HeaderBar from './components/HeaderBar.vue'
import SidePanel from './components/SidePanel.vue'
import useScreenAdapt from './hooks/useScreenAdapt'

// 使用屏幕适配
useScreenAdapt()

onMounted(() => {
  AMapLoader.load({
    key: 'cf9497a1463f0a071d745a14277bbc11',
    version: '2.0'
  }).then((AMap) => {
    // 卫星图层
    const satelliteLayer = new AMap.TileLayer.Satellite({ zIndex: 1 });
    // 路网标注图层（显示地名）
    const roadNetLayer = new AMap.TileLayer.RoadNet({ zIndex: 2, opacity: 0.5 });

    // 只高亮黑龙江省
    const HLJ_ADCODE = '230000';
    
    // 行政区划图层
    const disCountry = new AMap.DistrictLayer.Country({
      zIndex: 10,
      SOC: 'CHN',
      depth: 1,
      styles: {
        'nation-stroke': 'rgba(255,255,255,0.7)', // 国界线白色
        'coastline-stroke': 'rgba(255,255,255,0.7)', // 海岸线白色
        'province-stroke': (props: any) => {
          // 黑龙江省边界高亮黄色，其它省份淡白色
          return props.adcode === '230000' ? '#ffffff' : 'rgba(255,255,255,0.2)';
        },
        'city-stroke': 'rgba(255,255,255,0.2)', // 市界线淡白色
        fill: (props: any) => {
          if (props.level === "province") {
            const adcode = String(props.adcode).substring(0, 6).padEnd(6, "0");
            if (adcode === HLJ_ADCODE) {
              return "rgba(118, 113, 119,0.56)";
            }
          }
          return "rgba(0,0,0,0)";
        },
      }
    });

    // 初始化地图
    const map = new AMap.Map('container', {
      zooms: [5, 18],
      center: [125.9688, 48.368],
      showIndoorMap: false,
      zoom: 6,
      isHotspot: false,
      defaultCursor: 'pointer',
      pitch: 0,
      layers: [
        satelliteLayer,
        roadNetLayer,
        disCountry
      ],
      viewMode: '3D'
    });

    // 隐藏logo和版权
    map.setStatus({ showLogo: false, showIndoorMap: false });
    map.setDefaultCursor('default');
  })
})
</script>

<template>
  <div class="app-container">
    <HeaderBar />
    <SidePanel />
    <div id="container"></div>
  </div>
</template>

<style>
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a1a2a;
}

#app {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 999;
  transform-origin: 0 0;
}

.app-container {
  position: relative;
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  transform-origin: 0 0;
}

#container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  box-shadow: 0 0 40px #00ffff44;
  border-radius: 12px;
  overflow: hidden;
}

.city-bar-section {
  margin-bottom: 18px;
}

.bar-title-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 2px;
}

.bar-title {
  font-size: 18px;
  font-weight: bold;
  color: #bfe6ff;
  letter-spacing: 2px;
  text-shadow: 0 0 8px #00cfff88;
}

.bar-unit {
  font-size: 13px;
  color: #bfe6ff;
  opacity: 0.7;
  margin-left: 8px;
}

.bar-chart-bg {
  position: relative;
  background: rgba(10, 20, 40, 0.7);
  border-radius: 8px;
  padding: 18px 8px 0 38px;
  height: 170px;
  display: flex;
  align-items: flex-end;
  box-shadow: 0 0 16px #00cfff22;
}

.bar-y-axis {
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 38px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 2;
}

.bar-y-label {
  color: #bfe6ff;
  font-size: 13px;
  opacity: 0.7;
  text-align: right;
  text-shadow: 0 0 6px #00cfff44;
}

.bar-chart-strict {
  display: flex;
  align-items: flex-end;
  height: 130px;
  gap: 32px;
  width: 100%;
  justify-content: center;
}

.bar-item-strict {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 44px;
}

.bar-value-strict {
  color: #35e0ff;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 4px;
  text-shadow: 0 0 8px #00cfff;
}

.bar-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 60% 40%, #35e0ff 80%, #0a1a2a 100%);
  box-shadow: 0 0 12px #35e0ff99, 0 0 2px #fff;
  margin-bottom: -6px;
  z-index: 2;
}

.bar-inner-strict {
  width: 18px;
  border-radius: 10px 10px 8px 8px;
  background: linear-gradient(180deg, #35a7e0 0%, #35e0ff 100%);
  box-shadow: 0 0 12px #35e0ff99;
  margin-bottom: 8px;
  transition: height 0.5s;
}

.bar-label-strict {
  color: #fff;
  font-size: 15px;
  margin-top: 6px;
  text-shadow: 0 0 8px #00cfff;
  font-weight: bold;
  letter-spacing: 1px;
}
</style>
